package com.ken.base_library.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment

/**
 * @author by ken
 * Blog:
 * Date:2020/5/9
 * Description:
 */
abstract class BaseFragment : Fragment() {
    lateinit var mView: View
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        mView = inflater.inflate(getLayoutId(), container, false)
        initDataBind(inflater)
        initView(mView, savedInstanceState)
        initListener()
        initData()
        return databing()
    }


    abstract fun initDataBind(inflater: LayoutInflater)
    /**
     * 该抽象方法就是 初始化view
     *
     * @param view
     * @param savedInstanceState
     */
    protected abstract fun initView(
        view: View?,
        savedInstanceState: Bundle?
    )

    abstract fun initListener()
    abstract fun initData()
    abstract fun getLayoutId(): Int

    abstract fun databing(): View
}